package com.deyuanyun.pic.pbf.controller.dto;

import java.math.BigDecimal;
import java.util.Date;

import com.alibaba.fastjson.annotation.JSONField;
import com.deyuanyun.pic.common.spring.SpringAppliction;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.common.util.poi.annotation.ExcelWriteColumn;
import com.deyuanyun.pic.common.util.web.Asserts;
import com.deyuanyun.pic.pbf.enumeration.DefectStateEnum;
import com.deyuanyun.pic.pbf.enumeration.RepairTaskStatedEnum;
import com.deyuanyun.pic.settings.controller.pipe.vo.PipeLocationDTO;
import com.deyuanyun.pic.settings.service.pipe.PipeLocationService;

/**
 * 维修项目前台需要的数据DTO。
 * 
 * @author ChenKui
 * @date 2016-06-20
 *
 */
public class RepairTaskDTO {

    private String repairTaskId;//维修任务编号
    @ExcelWriteColumn
    private String name;//维修任务名称
    
    private String pipeLineId;//管道编号
    private String pipeLineName;//管道名称
    
    //private String pipeSegmentId;//管段编号
    //private String pipeSegmentName;//管段名称
    private String fromPointId;//起点编号
    private String toPointId;//终点编号
    
    private String fromPointName;//起点名称
    private String toPointName;//起点名称
    private BigDecimal fromPointMile;//起点绝对距离
    private BigDecimal endPointMile;//终点绝对距离
    
    
    private DefectStateEnum dataState;//数据状态：已保存，发布
    private RepairTaskStatedEnum repairState;//修复状态枚举
    private String dataState_label;//枚举的返回中文（根据两个枚举值来判断过后的，因为前端是两个枚举的融合状态）

    //--------------工作量---------------//
    @ExcelWriteColumn
    private Integer coatRepair;//防腐层修复
    @ExcelWriteColumn
    private Integer compositesRepair;//复合材料补强修复
    @ExcelWriteColumn
    private Integer epoxySleeveRepair;//钢质环氧套筒补强修复
    @ExcelWriteColumn
    private Integer atypeSleeveRepair;//A型套筒补强修复
    @ExcelWriteColumn
    private Integer btypeSleeveRepair;//B型套筒补强修复
    @ExcelWriteColumn
    private Integer excavationVerification;//开挖验证
    @ExcelWriteColumn
    private Integer pipeReplacement;//换管
    @ExcelWriteColumn
    private Integer otherRepairWf;//其他修复流程

    @ExcelWriteColumn
    private String assemblyCompany;//施工单位
    @ExcelWriteColumn
    private Date planStartDate;//建议开工时间
    @ExcelWriteColumn
    private Date planCompletionDate;//建议竣工时间
    
    private Date releaseDate;//发布时间
    
    private Date createDate;//创建时间

    public String getDataState_label() {
        if(dataState == DefectStateEnum.state20 ){//如果已发布了，就取修复状态
            if(repairState != null){//数据有可能没有状态
                dataState_label = repairState.getLabel();
            }
            
        }else{
            dataState_label = RepairTaskStatedEnum.valueOf(dataState.toString()).getLabel();
        }
        return dataState_label;
    }
    
    //获取起点位置名称
    public String getFromPointName() {
        if(StringUtils.isNotEmpty(fromPointName)){
            return fromPointName;
        }
        if(StringUtils.isEmpty(fromPointId)){
            return fromPointName;
        }
        PipeLocationService pipeLocationService = (PipeLocationService)SpringAppliction.getBean(PipeLocationService.class);
        PipeLocationDTO pipeLocation = pipeLocationService.queryPipeLocationById(pipeLineId,fromPointId);
        Asserts.assertTrue(pipeLocation != null, "没有找到起点编号对应的桩或者场站阀室、" + fromPointId);
        fromPointName = pipeLocation.getName();
        //fromPointMile = pipeLocation.getMileage();
        return fromPointName;
    }

    //获取终点位置名称
    public String getToPointName() {
        if(StringUtils.isNotEmpty(toPointName)){
            return toPointName;
        }
        if(StringUtils.isEmpty(toPointId)){
            return toPointName;
        }
        PipeLocationService pipeLocationService = (PipeLocationService)SpringAppliction.getBean(PipeLocationService.class);
        PipeLocationDTO pipeLocation = pipeLocationService.queryPipeLocationById(pipeLineId,toPointId);
        Asserts.assertTrue(pipeLocation != null, "没有找到终点编号对应的桩或者场站阀室、" + toPointId);
        toPointName = pipeLocation.getName();
        //endPointMile = pipeLocation.getMileage();
        return toPointName;
    }

    //TODO 待验证：这个地方返回格式待处理。
    @JSONField(format="yyyy-MM-dd")
    public Date getPlanStartDate() {
        return planStartDate;
    }
    
    @JSONField(format="yyyy-MM-dd")
    public Date getPlanCompletionDate() {
        return planCompletionDate;
    }
    //----------以下为自动生成-----------//
    
    
    public String getRepairTaskId() {
        return repairTaskId;
    }
    
    public BigDecimal getFromPointMile() {
        return fromPointMile;
    }

    public BigDecimal getEndPointMile() {
        return endPointMile;
    }

    public void setFromPointMile(BigDecimal fromPointMile) {
        this.fromPointMile = fromPointMile;
    }

    public void setEndPointMile(BigDecimal endPointMile) {
        this.endPointMile = endPointMile;
    }

    public String getFromPointId() {
        return fromPointId;
    }

    public String getToPointId() {
        return toPointId;
    }

    public void setFromPointId(String fromPointId) {
        this.fromPointId = fromPointId;
    }

    public void setToPointId(String toPointId) {
        this.toPointId = toPointId;
    }

    public Date getReleaseDate() {
        return releaseDate;
    }

    public void setReleaseDate(Date releaseDate) {
        this.releaseDate = releaseDate;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public RepairTaskStatedEnum getRepairState() {
        return repairState;
    }

    public void setRepairState(RepairTaskStatedEnum repairState) {
        this.repairState = repairState;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setRepairTaskId(String repairTaskId) {
        this.repairTaskId = repairTaskId;
    }
    
    public String getPipeLineId() {
        return pipeLineId;
    }
    public String getPipeLineName() {
        return pipeLineName;
    }
    public DefectStateEnum getDataState() {
        return dataState;
    }
    public Integer getCoatRepair() {
        return coatRepair;
    }
    public Integer getCompositesRepair() {
        return compositesRepair;
    }
    public Integer getEpoxySleeveRepair() {
        return epoxySleeveRepair;
    }
    public Integer getAtypeSleeveRepair() {
        return atypeSleeveRepair;
    }
    public Integer getBtypeSleeveRepair() {
        return btypeSleeveRepair;
    }
    public Integer getPipeReplacement() {
        return pipeReplacement;
    }
    public Integer getExcavationVerification() {
        return excavationVerification;
    }
    public Integer getOtherRepairWf() {
        return otherRepairWf;
    }
    public String getAssemblyCompany() {
        return assemblyCompany;
    }
    
    public void setPipeLineId(String pipeLineId) {
        this.pipeLineId = pipeLineId;
    }
    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }
    public void setDataState(DefectStateEnum dataState) {
        this.dataState = dataState;
    }
    public void setCoatRepair(Integer coatRepair) {
        this.coatRepair = coatRepair;
    }
    public void setCompositesRepair(Integer compositesRepair) {
        this.compositesRepair = compositesRepair;
    }
    public void setEpoxySleeveRepair(Integer epoxySleeveRepair) {
        this.epoxySleeveRepair = epoxySleeveRepair;
    }
    public void setAtypeSleeveRepair(Integer atypeSleeveRepair) {
        this.atypeSleeveRepair = atypeSleeveRepair;
    }
    public void setBtypeSleeveRepair(Integer btypeSleeveRepair) {
        this.btypeSleeveRepair = btypeSleeveRepair;
    }
    public void setPipeReplacement(Integer pipeReplacement) {
        this.pipeReplacement = pipeReplacement;
    }
    public void setExcavationVerification(Integer excavationVerification) {
        this.excavationVerification = excavationVerification;
    }
    public void setOtherRepairWf(Integer otherRepairWf) {
        this.otherRepairWf = otherRepairWf;
    }
    public void setAssemblyCompany(String assemblyCompany) {
        this.assemblyCompany = assemblyCompany;
    }
    public void setPlanStartDate(Date planStartDate) {
        this.planStartDate = planStartDate;
    }
    public void setPlanCompletionDate(Date planCompletionDate) {
        this.planCompletionDate = planCompletionDate;
    }

    
}
